How do I get rid of `^M' or echoed commands in my shell buffer?
===============================================================
Try typing `M-x shell-strip-ctrl-m <RET>' while in `shell-mode' to
make them go away. If that doesn't work, you have several options:
For `tcsh', put this in your `.cshrc' (or `.tcshrc') file:
if ($?EMACS) then
if ("$EMACS" == t) then
if ($?tcsh) unset edit
stty nl
endif
endif
Or put this in your `.emacs_tcsh' file:
unset edit
stty nl
Alternatively, use `csh' in your shell buffers instead of `tcsh'.
One way is:
(setq explicit-shell-file-name "/bin/csh")
and another is to do this in your `.cshrc' (or `.tcshrc') file:
setenv ESHELL /bin/csh
(You must start Emacs over again with the environment variable properly
set for this to take effect.)
You can also set the `ESHELL' environment variable in Emacs Lisp
with the following Lisp form,
(setenv "ESHELL" "/bin/csh")
The above solutions try to prevent the shell from producing the `^M'
characters in the first place. If this is not possible (e.g., if you
use a Windows shell), you can get Emacs to remove these characters from
the buffer by adding this to your `.emacs' init file:
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m)
On a related note: If your shell is echoing your input line in the
shell buffer, you might want to try the following command in your shell
start-up file:
stty -icrnl -onlcr -echo susp ^Z